<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>数据类型转换练习</title>
    <style>
        body{
            padding: 50px;
            font-size: 20px;
        }
    </style>
</head>
<body>

<script>
//转换为 Number 类型
    var a = '123.456img';
    var a1 = parseInt(a);
    var a2 = parseFloat(a);
    var a3 = Number(a);  
    document.write("a1="+ a1 + '<br/>'+"a2="+ a2+ '<br/>'+"a3="+ a3+ '<br/>');
    document.write(typeof a2 +"<br/><br/>");

//转换成String类型
    var b = 3.1415926;
    var b1 = b + "";
    var b2 = String(b);
    document.write(typeof b1 +"<br/>");
    document.write(typeof b2 +"<br/><br/>");

//转换成Boolean类型
    var c = "img" + 3 + ".jpg";
    var c1 = !!c;
    document.write("c1 = "+c1+ '<br/>');
    document.write(typeof c1);
</script>

</body>
</html>